import request from '@/utils/request'

/**
 * 添加购物车
 * @param {String} skuId
 * @param {Number} count
 * @returns {Promise}
 */
export const insertCartApi = ({ skuId, count }) => {
  return request({
    url: '/member/cart',
    method: 'post',
    data: {
      skuId,
      count,
    },
  })
}

/**
 * 获取购物车列表
 * @returns {Promise}
 */
export const getCartListApi = () => {
  return request({
    url: '/member/cart',
    method: 'get',
  })
}

/**
 * 删除购物车商品
 * @param {Array} ids 商品id数组
 * @returns {Promise}
 */
export const deleteCartApi = (ids) => {
  return request({
    url: '/member/cart',
    method: 'delete',
    data: {
      ids,
    },
  })
}

/**
 * 合并购物车
 * @param {Array} cartList 购物车列表
 * @returns {Promise}
 */
export const mergeCartApi = (cartList) => {
  return request({
    url: '/member/cart/merge',
    method: 'post',
    data: cartList,
  })
}
